<%@page import="com.renyibao.mteaf.ext.client.util.RandomUtil"%>
<%@page import="com.witnsoft.mteaf.core.util.Tools"%>
<%@page import="net.minidev.json.JSONValue"%>
<%@page import="net.minidev.json.JSONArray"%>
<%@ page contentType="text/html; charset=utf-8"  buffer="none" %>
<%@ page import="com.puda.mteaf.core.util.*"%>
<%@ page import="com.pukea.app.medical.wx.gzh.patient.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.witnsoft.mteaf.core.util.*"%>
<%@ page import="javax.sql.rowset.*"%>
<%
/* String ip = "http://localhost:8080"; */
String ip = "https://zy.renyibao.com";
String wpid = RandomUtil.generateString(16);
%>
	<link href="<%=ip %>/doctor/plug_in/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="<%=ip %>/doctor/plug_in/css/htmleaf-demo.css">
	<link rel="stylesheet" href="<%=ip %>/doctor/plug_in/assets/css/jquery.mCustomScrollbar.min.css" />
    <link rel="stylesheet" href="<%=ip %>/doctor/plug_in/assets/css/custom.css">
		
    <style type="text/css">
    	.content {
    		width:84%;
    	}
    	.plug-in-page .sidebar-menu .sidebar-dropdown span {
    		color:#ccc;
    		font-size: 8px;
    	}
    	
    	.alWindow {
            display: none; 
            position: fixed; 
            top: 25%; 
            left: 25%; 
            width: 35%; 
            height: 60%; 
            padding: 20px; 
            border: 3px solid #ccc; 
            background-color: white;
            z-index:2; 
            overflow: auto; 
        }
        .albackGround {
            display: none; 
            position: absolute; 
            top: 0%; 
            left: 0%; 
            width: 100%; 
            height: 1100px; 
            background-color: black; 
            z-index:1; 
            -moz-opacity: 0.8; 
            opacity:.80; 
            filter: alpha(opacity=88);
        }
    	
    	.msgWindow {
            display: none; 
            position: fixed; 
            top: 40%; 
            left: 25%; 
        }
    	
    	.msgCon {
		    z-index: 999999;
		    position: fixed;
        }
    	
        .msgBox {
		    width: 100%;
		    height: 100%;
		    z-index: 99999;
		    position: fixed;
		    background-color: black;
		    top: 0px;
		    left: 0px;
		    opacity: 0.6;
        }
        
        #x:hover {cursor: pointer;color: rgb(55,198,192);}
        #deli_x:hover {cursor: pointer;color: rgb(55,198,192);}
        #msg-x:hover {cursor: pointer;color: rgb(55,198,192);}
        
        .input-text {
		    width: 100%;
		    height: 28px;
		    line-height: 28px;
		    border-radius: 2px;
		    background: #fff;
		    text-indent: 9px;
		    font-size: 14px;
		}
		
		.plug-btn-save {
		    background-color: #4caf50;
		    color: #fff;
		    position: fixed;
		    margin-left: 140px;
		    margin-top: 50px;
		    width: 80px;
		    border-radius: 3px;
		}
		
		.plug-btn-cancel {
		    position: fixed;
		    margin-left: 240px;
		    margin-top: 50px;
		    width: 80px;
		    border-radius: 3px;
		}
		
		.plug-btn-refresh {
		    color: #65ea5d;
		    margin-left: 30%;
		    margin-top: 50px;
		    width: 80px;
		    border-radius: 3px;
		    cursor: pointer;
		}
		
		.foot-icon {
			width:1.5rem;
		}
		
		.xiala-icon {
			width:1rem;
		}
		
		.yuanquan-icon {
			width:0.75rem;
		}
    	
    	
    </style>
	<div class="plug-in-page toggled">
            <div class="page-content">
                <div class="sidebar-content">
                <a href="javascript:void(0)" id="toggle-sidebar"><i class="fa fa-bars"></i></a>
                <div class="sidebar-brand">
                    <a href="javascript:void(0)" id="hospital"></a><span id="refresh" class="plug-btn-refresh">刷新</span>
                </div>
                
                <div id="QRcodePrint" class="alWindow">
		            <label id="printx" style="position: absolute;top:2px;left: 95%;font-size: 25px;">x</label>
		            <form>
		                <div><a id="printReceive">打印</a></div>
		                <div id="printReceiveContext">
		                	<div id="printQrcode"></div>
			                <div><b>收货人    </b> <b id="lxrxm"></b></div>
		                	<div><b>联系电话</b> <b id="lxrdh"></b></div>
		                	<div><b>收货地址</b> <b id="qjdz"></b></div>
		                	<div><b>订单编号</b> <b id="ordcode"></b></div>
		                	<div><b>开方时间</b> <b id="actime"></b></div>
		                	<div><b>付款时间</b> <b id="fktime"></b></div>
		                	<div><b>发货时间</b> <b id="delivertime"></b></div>
		                </div>
		            </form>
		        </div>
		        <div id="PrintbackGround" class="albackGround"></div>
                
                <div id="QRcodeWindow" class="alWindow">
		            <label id="x" style="position: absolute;top:2px;left: 95%;font-size: 25px;">x</label>
		            <form>
		                <div id="qrcode">
		                	
		                </div>
		
		            </form>
		        </div>
		        <div id="QRcodebackGround" class="albackGround"></div>
                
                <div id="MessageWindow" class="msgWindow">
		            <div class="msgBox"></div>
		            <div class="msgCon">
			            <iframe src="<%=ip %>/doctor/plug_in/effect/wait.html"></iframe>
			            <div>
				            <label id="msg-x" style="position: absolute;top:-5px;left: 93%;font-size: 22px;">x</label>
			            </div>
		            </div>
		        </div>
		        <div id="MessagebackGround" class="albackGround"></div>
		        
		        <div id="deliverWindow" class="alWindow">
		            <label id="deli_x" style="position: absolute;top:2px;left: 95%;font-size: 25px;">x</label>
		            <form style="">
		            	<div><span style="font-size: 40px;">填写快递信息</span></div>
	            		<table style="width: 100%;font-size: 14px;margin-top: 50px;">
	            			<tbody style="line-height: 45px;">
			            		<tr><td>收件人</td><td>
			            		<input type="text" id="lxrxm-deli" class="input-text" disabled="disabled"/></td></tr>
			            		<tr><td>联系电话</td><td>
			            		<input type="text" id="lxrdh-deli" class="input-text" disabled="disabled"/></td></tr>
			            		<tr><td>收货地址</td><td>
			            		<input type="text" id="qjdz-deli" class="input-text" disabled="disabled"/></td></tr>
			            		<tr><td>快递名称</td>
				            		<td>
					            		<select class="input-text" id = "kdmc">
					            			<option value="zhongtong">中通快递</option>
					            			<option value="yuantong">圆通快递</option>
					            			<option value="shunfeng">顺丰快递</option>
					            		</select>
				            		</td>
			            		</tr>
			            		<tr><td>快递单号</td><td>
			            		<input type="text" id="kdno" class="input-text"/></td></tr>
		            		</tbody>
						</table>
						<div>
							<input type="button" id="save_deliver_info" class="plug-btn-save" value="保存"/>
							<input type="button" id="cancel" class="plug-btn-cancel" value="取消"/>
						</div>
		            </form>
		        </div>
		        <div id="deliverbackGround" class="albackGround"></div>
                
                <div class="sidebar-header">
                    <div class="user-pic">
                        <img class="img-responsive img-rounded" src="<%=ip %>/doctor/plug_in/assets/img/user.jpg" alt="">
                    </div>
                    <div id="docinfo" class="user-info">
                    </div>
                </div>
                <div class="sidebar-menu">
                    <ul id="hzdj" style="display: block;">
                        <li class="header-menu"><span>患者登记</span></li>
                        <li class="sidebar-dropdown">
                            <a  href="javascript:void(0)" ><i class="fa fa-tv"></i><span>待登记的患者</span><span id="conncount" class="label label-danger"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="conn">
                                </ul>
                            </div>
                        </li>                  
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>已登记的患者</span><span id="conycount" class="badge"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="cony">
                                </ul>
                            </div>
                        </li>               
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>未来三天内预约</span><span id="3dayscount" class="badge"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="3days">
                                </ul>
                            </div>
                        </li>
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>未绑定微信患者</span><span id="unwxcount" class="label label-success"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="unwx">
                                </ul>
                            </div>
                        </li>
                    </ul>
                    <ul id="jrjz" style="display: none;">
                        <li class="header-menu"><span>今日就诊</span></li>
                        <li class="sidebar-dropdown">
                            <a  href="javascript:void(0)" ><i class="fa fa-tv"></i><span>今日开药</span><span id="ordycount" class="label label-danger"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="ordy">
                                </ul>
                            </div>
                        </li>       
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>历史药方</span><span id="ordncount" class="badge"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="ordn">
                                </ul>
                            </div>
                        </li>
                     </ul>
                     <ul id="sfgl" style="display: none;">
                        <li class="header-menu"><span>收费管理</span></li>
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>未支付</span><span id="payncount" class="badge"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="payn">
                                </ul>
                            </div>
                        </li>
                        <li class="sidebar-dropdown">
                            <a  href="javascript:void(0)" ><i class="fa fa-tv"></i><span>已支付未确认</span><span id="payucount" class="label label-danger"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="payu">
                                </ul>
                            </div>
                        </li>                  
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>已支付已确认</span><span id="payycount" class="badge"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="payy">
                                </ul>
                            </div>
                        </li>
                    </ul>
                    <ul id="yffh" style="display: none;">
                        <li class="header-menu"><span>药方发货</span></li>
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>未发药</span><span id="deliverncount" class="label label-danger"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="deli_n">
                                </ul>
                            </div>
                        </li>
                        <li class="sidebar-dropdown">
                            <a  href="javascript:void(0)" ><i class="fa fa-tv"></i><span>已发药</span><span id="deliverycount" class="label label-success"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="deli_y">
                                </ul>
                            </div>
                        </li>                  
                        <li class="sidebar-dropdown">
                            <a href="javascript:void(0)"><i class="fa fa-photo"></i><span>已收药</span><span id="takecount" class="badge"></span><img class="xiala-icon" src="<%=ip %>/doctor/plug_in/icon/xiala.png"></a>
                            <div class="sidebar-submenu">
                                <ul id="take_y">
                                </ul>
                            </div>
                        </li>
                    </ul>
                   </div>       
                </div>
        
                <div class="sidebar-footer">
                    <a class="sidebar-hzdj"><i class="fa fa-bell"><img class="foot-icon" src="<%=ip %>/doctor/plug_in/icon/dengji.png"><span id="pat_register" class="label label-warning notification"></span></i><br/>患者登记</a>
                    <a class="sidebar-jrjz"><i class="fa fa-envelope"><img class="foot-icon" src="<%=ip %>/doctor/plug_in/icon/jiuzhen.png"><span id="ord_today" class="label label-warning notification"></span></i><br/>今日就诊</a>
                    <a class="sidebar-sfgl"><i class="fa fa-gear"><img class="foot-icon" src="<%=ip %>/doctor/plug_in/icon/shoufeiguanli.png"><span id="pay_manage" class="label label-warning notification"></span></i><br/>收费管理</a>
                    <a class="sidebar-yffh"><i class="fa fa-gear"><img class="foot-icon" src="<%=ip %>/doctor/plug_in/icon/fahuo.png"><span id="ord_deliver" class="label label-warning notification"></span></i><br/>药方发货</a>
                </div>
            </div>
        </div>
<script type="text/javascript">
var url = '<%=ip %>/doctor/AppMainServlet.ap';
var ip = '<%=ip %>';
var wpid = '<%=wpid%>';
var QRurl = '<%=ip %>/doctor/plug_in/QRwxbinding.jsp';
var token = "";
var locstorage = eval('('+localStorage.getItem("medical_user_data")+')');
var userid = locstorage.employee.employeeId;
var username = locstorage.employee.employeeName;
var hosid = locstorage.employee.clinicId;
//console.log("userid="+userid);
//console.log("hosid="+hosid);
//绑定dom
var InterDoctorRota;
var iframeContent = $("#r-main").find("#paFrame").contents();
var checkDoctorRota = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log(iframeContent.find(".doctor-rota").length);
	console.log(iframeContent.find("#pa-save").length);
	if(iframeContent.find(".doctor-rota").length > 0&&iframeContent.find("#saveAndSubApptSchedule").length){
		clearInterval(InterDoctorRota); 
		iframeContent.find("#saveAndSubApptSchedule").before("<div id=\"plug_Schedule_save\" style=\"background-color: #4CAF50;padding: 5px 30px;display: inline-block;font-size: 15px;margin: 0px 5px;cursor: pointer;border-radius:3px;margin-top: 10px;\"><span style=\"color:#fff\">发送到微信</span></div>");
		InterDoctorRota = setInterval("schedule(InterDoctorRota)", 1000);
	};
};
var schedule = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log(iframeContent.find("#plug_Schedule_save").length);
	if(iframeContent.find("#plug_Schedule_save").length>0){
		clearInterval(InterDoctorRota); 
		iframeContent.find("#plug_Schedule_save").bind("click",function(){
			$("#MessageWindow").slideDown(300);
	        $("#MessagebackGround").show();
		 	getSchedule();
		});
	}
};
var recipeId = '';
var patname = '';
var cash = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log(iframeContent.find("#chargebtnid").length);
	console.log(iframeContent.find(".recipeId").length);
	if(iframeContent.find("#chargebtnid").length>0&&iframeContent.find(".recipeId").length>0){
		iframeContent.find("#chargebtnid").bind("click",function(){
			recipeId = iframeContent.find(".recipeId").val();
			patname = iframeContent.find("#patient_name").html();
		  	console.log("patname:"+patname+",recipeId:"+recipeId);
		  //console.log("收费测试！！！");
		  clearInterval(InterDoctorRota);
		  InterDoctorRota = setInterval("concernPay(InterDoctorRota)", 1000);
		});
		clearInterval(InterDoctorRota); 
	}
};
var concernPay = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents().find("#pay_pop")
		.find("iframe[name='chargePayPanel']").contents();
	console.log(iframeContent.find("#pay_confirm_btn").length);
	if(iframeContent.find("#pay_confirm_btn").length>0){
		iframeContent.find("#pay_confirm_btn").bind("click",function(){
		  
		  concernPayment(recipeId,patname,userid,"");
		
		});
		clearInterval(InterDoctorRota); 
	}
};
var OPC_DWS0912 = function(){
	console.log($(".menuBox").length);
	if($(".menuBox").length>0){
		$("#OPC_DWS0912").bind("click",function(){
			console.log("绑定中草药方按钮！");
			clearInterval(InterDoctorRota);
			InterDoctorRota = setInterval("recipemanage(InterDoctorRota)", 1000);
		});
		$("#OPC_DWS096").bind("click",function(){
			console.log("绑定中草药方按钮！");
			clearInterval(InterDoctorRota);
			InterDoctorRota = setInterval("recipemanage(InterDoctorRota)", 1000);
		});
		clearInterval(InterDoctorRota);
		InterDoctorRota = setInterval("recipemanage(InterDoctorRota)", 1000);
	}
};
var recipemanage = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log(iframeContent.find(".right-btn").length);
	if(iframeContent.find(".right-btn").length>0){
		clearInterval(InterDoctorRota); 
		iframeContent.find(".right-btn").before("<div id=\"plug_in_save\" style=\"background-color: #4CAF50;padding: 5px 30px;display: inline-block;font-size: 15px;margin: 0px 5px;cursor: pointer;border-radius:3px;\"><span style=\"color:#fff\">发送到微信</span></div>");
		InterDoctorRota = setInterval("saverecipe(InterDoctorRota)", 1000);
	}
};
var saverecipe = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	var temp = $("#r-main").find("#paFrame").attr("src");
	var datatemp = "&"+temp.substring(temp.indexOf("empiId"),temp.indexOf("treatmentState")-1);
	//console.log(datatemp);
	console.log(iframeContent.find("#plug_in_save").length);
	if(iframeContent.find("#plug_in_save").length>0){
		clearInterval(InterDoctorRota); 
		iframeContent.find("#plug_in_save").bind("click",function(){
			getRecipe(datatemp);
		});
	}
};
var saledrug = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents().find("#recipe_info");
	console.log("btn-group",iframeContent.find(".btn-group").length);
	console.log("confirm-drug",iframeContent.find(".btn.normal-btn.fl.confirm-drug").length);
	if(iframeContent.find(".btn.normal-btn.fl.confirm-drug").length>0){
		clearInterval(InterDoctorRota);
		var clickstatus = iframeContent.find(".btn.normal-btn.fl.confirm-drug").attr("clickstatus");
		if(clickstatus=='1'){
		
		}else{
			iframeContent.find(".btn-group").append("<br/><div id=\"plug_ziti\" style=\"background-color: #4CAF50;display: inline-block;font-size: 15px;margin: 10px;cursor: pointer;border-radius:3px;text-align: center;padding: 0px 10px;\"><span style=\"color: #fff;width: 100%;padding: 0px;\">自提</span></div><div id=\"plug_deliver_drug\" style=\"background-color: #4CAF50;display: inline-block;font-size: 15px;cursor: pointer;border-radius:3px;text-align: center;padding: 0px 10px;\"><span style=\"width: 100%;color:#fff;padding: 0px;\">填写快递信息</span></div>");
			clearInterval(InterDoctorRota);
			InterDoctorRota = setInterval("deliver_drug(InterDoctorRota)", 1000);
		}
	};
};
var recipeid = "";
var deliver_drug = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log("recipe_info",iframeContent.find("#recipe_info .recipeInfo").length);
	if("recipe_info",iframeContent.find("#recipe_info .recipeInfo").length>0){
		clearInterval(InterDoctorRota);
		recipeid = iframeContent.find("#recipe_info .recipeInfo").attr("recipeid");
		//console.log("recipeid:"+recipeid);
		InterDoctorRota = setInterval("findrecipeid(InterDoctorRota)", 1000);
	};
};
var findrecipeid = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log("plug_deliver_drug",iframeContent.find("#plug_deliver_drug").length);
	console.log("plug_ziti",iframeContent.find("#plug_ziti").length);
	if(iframeContent.find("#plug_deliver_drug").length>0&&iframeContent.find("#plug_ziti").length>0){
		clearInterval(InterDoctorRota);
		//console.log("param:"+param);
		iframeContent.find("#plug_deliver_drug").bind("click",function(){
			deliverInfo();
			$("#deliverWindow").slideDown(300);
       		$("#deliverbackGround").show();
		});
		iframeContent.find("#plug_ziti").bind("click",function(){
			ziti();
		});
	}
};
var patient_reg = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log(iframeContent.find("#reg_complete_btn").length);
	if(iframeContent.find("#reg_complete_btn").length>0){
		clearInterval(InterDoctorRota);
		iframeContent.find("#reg_complete_btn").bind("click",function(){
			clearInterval(InterDoctorRota);
			InterDoctorRota = setInterval("waitPatInfo(InterDoctorRota)", 1000);
		});
	};
};
var waitPatInfo = function(){
	var iframeContent = $("#r-main").find("#paFrame").contents();
	console.log(iframeContent.find("#patiName").length);
	if(iframeContent.find("#patiName").length>0&&iframeContent.find("#patiName").val()==''){
		clearInterval(InterDoctorRota);
		getRegPatientlist();
	}
};
$(function(){
	//绑定触发
	var iframeContent = $("#r-main").find("#paFrame").contents();
	$("#order_management").bind("click",function(){
		clearInterval(InterDoctorRota);
		//console.log(111);
		$("#APT03").bind("click",function(){
			clearInterval(InterDoctorRota);
			InterDoctorRota = setInterval("checkDoctorRota(InterDoctorRota)", 1000);
		});
	});
	$("#charging_management").bind("click",function(){
		clearInterval(InterDoctorRota);
		InterDoctorRota = setInterval("cash(InterDoctorRota)", 1000);
	});
	$("#patient_center").bind("click",function(){
		clearInterval(InterDoctorRota);
		//console.log(111);
		InterDoctorRota = setInterval("OPC_DWS0912(InterDoctorRota)", 1000);
	});
	$("#patient_management").bind("click",function(){
		clearInterval(InterDoctorRota);
		//console.log(222);
		InterDoctorRota = setInterval("patient_reg(InterDoctorRota)", 1000);
		$("#PATREG01").bind("click",function(){
			clearInterval(InterDoctorRota);
			InterDoctorRota = setInterval("patient_reg(InterDoctorRota)", 1000);
		});
	});
	$("#sale_drug").bind("click",function(){
		clearInterval(InterDoctorRota);
		console.log(333);
		InterDoctorRota = setInterval("saledrug(InterDoctorRota)", 1000);
	});
	$("#medicine_management").bind("click",function(){
		clearInterval(InterDoctorRota);
	});
	$("#refresh").bind("click",function(){
		clearInterval(InterDoctorRota);
		console.log("刷新。。。。");
		init();
	});
	
	logginCheck();
	
	//setInterval(init,10000);
});

	function init(){
		getPatientlistY();
		getPatientlistN();
		getPatientlist3days();
		getWxUnbindPatlistY();
		getOrderListY();
		getOrderListN();
		getPayRecordU();
		getPayRecordN();
		getPayRecordY();
		getOrderDeliverN();
		getOrderDeliverY();
		getOrderTake();
	}

//事件业务处理
	var appid;
	var patientno;
	$(document).on("click","#QRcode",function(){
		var title = this.title;
		var titles = title.split(",");
		console.log("item:"+titles);
		patientno = titles[1];
		getWxbindQRcode(titles[1],titles[0]);
		/* QRurl += '?patient_blhm='+titles[1]+'&patient_name='+encodeURI(encodeURI(titles[0]))+'&hosid='+hosid
			+'&userid='+userid+'&token='+token;
		window.open(QRurl); */
		$("#QRcodeWindow").slideDown(300);
        $("#QRcodebackGround").show();
        clearInterval(InterDoctorRota);
        sendReq();
        //InterDoctorRota = setInterval("listenQrcode()", 1000);
	});
	/* var listenQrcode = function(){
		var tn = "F27.APP.11.12";
		var param = "\{\"patientno\"\:\""+patientno+"\"\}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			console.log(item);
			if(item!=null&&item.length>0){
            	clearInterval(InterDoctorRota);
				$("#QRcodeWindow").slideUp(300);
            	$("#QRcodebackGround").hide();
            	alert("提示","绑定微信用户成功！",function(){
            		getWxUnbindPatlistY();
            	});
			}
		};
		myRequest(url,tn,param,success);
	}; */
	
	var sendReq = function (){
		var theurl = 'https://zyext.renyibao.com/ExtService?fid=wait';
		//$('#msg').html("等待响应..."+sendCount);
		$.ajax({
			  type: 'POST',
			  url: theurl,
			  data: '&wpevent=wait.push.common&wpid=<%=wpid%>',
			  success: function(data){
				 console.info(data);
				 var msg = "";
				 //$('#msg').html("响应结果..."+data);
				 //转json
				 var jo = JSON.parse($.trim(data));
				 if(jo['errCode'] != '200'){
					if(sendCount<10){ 
				 	   sendReq();
					   sendCount++;
					}
				 }else {
				 	$("#QRcodeWindow").slideUp(300);
	            	$("#QRcodebackGround").hide();
	            	alert("提示","绑定微信用户成功！",function(){
	            		getWxUnbindPatlistY();
	            	});
				 }
			  }
			  
			});
	}
	
	$(document).on("click","#doPrintReceive",function(){
		acno = this.title;
		console.log("item:"+acno);
		getReceiveQrcode(patient_blhm,patient_name,acno);
	});
	
	$(document).on("click","#quickAdd",function(){
		appid = this.title;
		console.log("item:"+appid);
		$("#r-main").find("#paFrame").attr("src","/clinic/patientManagement/patientManagement.html");
		clearInterval(InterDoctorRota);
		InterDoctorRota = setInterval("getPatientN(appid)", 1000);
	});
	
	$(document).on("click","#quickConcern",function(){
		clearInterval(InterDoctorRota);
		console.log("测试。。。");
		$("#r-main").find("#paFrame").attr("src","/clinic/chargeManagement/pricingCharge.html");
		InterDoctorRota = setInterval("cash(InterDoctorRota)", 1000);
	});
	
	$("#save_deliver_info").bind("click",function(){
		var param = "\{\"recipeid\"\:\""+recipeid+"\",";
		
		var kdmc = $("#kdmc").val();//快递名称全拼
		var kdno = $("#kdno").val();//快递单号
		
		if(kdmc==''){
			alert("提示","请选择快递名称！",function(){
				return false;
			});
		}
		if(kdno==''){
			alert("提示","请填写快递单号！",function(){
				return false;
			});
		}
		
		param += "\"kdmc\"\:\""+kdmc+"\",";//快递名称全拼
		param += "\"kdno\"\:\""+kdno+"\"";
		param += "\}";
		
		console.log("param:"+param);
		deliverdrug(param);
	});
	
	var patient_blhm='';
	var patient_name='';
	function deliverInfo(){
		var tn = "F27.APP.11.11";
		var param = "\{\"recipeid\"\:\""+recipeid+"\"\}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			console.log(item);
			if(item.length>0){
				$("#lxrxm-deli").val(item[0].LXRXM);
				$("#lxrdh-deli").val(item[0].LXRDH);
				$("#qjdz-deli").val(item[0].QJDZ);
				$("#kdmc").val(item[0].KDMC);
				$("#kdno").val(item[0].KDNO);
				patient_blhm = item[0].PATIENT_BLHM;
				patient_name = item[0].PATIENT_NAME;
				console.log(patient_blhm,patient_name);
			}
		};
		myRequest(url,tn,param,success);
	}
	
	function ziti(){
		var tn = "F27.APP.11.14";
		var param = "\{\"recipeid\"\:\""+recipeid+"\"\}";
		var success = function(data){
			alert("提示","药品已自提！",function(){
				getOrderDeliverN();
				getOrderDeliverY();
				getOrderTake();
	        	$("#hzdj").hide(1000);
	        	$("#jrjz").hide(1000);
	        	$("#sfgl").hide(1000);
	        	$("#yffh").show(1000);
			});
			
		};
		myRequest(url,tn,param,success);
	}
	
	function getReceiveQrcode(patient_blhm,patient_name,recipeid){
		var tn = "F27.APP.11.13";
		var param = "\{\"hosid\"\:\""+hosid+"\","+"\"userid\"\:\""+userid+"\","
			+"\"patient_blhm\"\:\""+patient_blhm+"\","+"\"patient_name\"\:\""+patient_name+"\","
			+"\"recipeid\"\:\""+recipeid+"\"\}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			console.log(item);
			if(item.length>0){
				var con = "<div><img style=\"height\:300px\;\" src=\""+item[0].QRURL+"\"></img></div>";
				$("#printQrcode").html(con);
				$("#lxrxm").html(item[0].LXRXM);
				$("#lxrdh").html(item[0].LXRDH);
				$("#qjdz").html(item[0].QJDZ);
				$("#ordcode").html(item[0].ORDCODE);
				$("#actime").html(item[0].ACTIME);
				$("#fktime").html(item[0].FKTIME);
				$("#delivertime").html(item[0].DELIVERTIME);
			}
			
			$("#QRcodePrint").slideDown(300);
	   		$("#PrintbackGround").show();
		};
		//console.log("param:",param);
		myRequest(url,tn,param,success);
		
	}
	
	$("#printReceive").bind("click",function(){
		bdhtml=window.document.body.innerHTML;//先保存当前页面
		document.body.innerHTML=document.getElementById('printReceiveContext').innerHTML;//获取需要打印的div
		window.print();
		window.document.body.innerHTML=bdhtml;//重新设置回当前页面
		
		$("#QRcodePrint").slideUp(300);
        $("#PrintbackGround").hide();
	});
	
	function deliverdrug(param){
		$("#deliverWindow").slideUp(300);
        $("#deliverbackGround").hide();
		var tn = "F27.APP.11.10";
		var success = function(data){
			//alert("发送成功！");
			console.log("发药信息发送成功。");
			getOrderDeliverN();
			getOrderDeliverY();
			getOrderTake();
        	$("#hzdj").hide(1000);
        	$("#jrjz").hide(1000);
        	$("#sfgl").hide(1000);
        	$("#yffh").show(1000);
        	
		};
		myRequest(url,tn,param,success);
	}
	
	function savePatInfo(patinfo){
		var tn = "F27.APP.11.06";
		var success = function(data){
			//alert("发送成功！");
			console.log("患者登记发送成功！");
			getWxUnbindPatlistY();
		};
		myRequest(url,tn,patinfo,success);
	}
	
	function checkOrder(ono,resp){
		var tn = "F27.APP.11.05";
		var param = "{\"ono\":\""+ono+"\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log(55555,item);
			var empi = resp.data.empi;
			var recipe = resp.data.lstPrescription[0];
			var recipeCnList = recipe.recipeCnList;
			var recipeTreatmentList = recipe.recipeTreatmentList;
			//console.log(1111,empi);
			//console.log(1111,recipeCnList);
			var patient_zdsm='';
			var kdfw='';
			var datames = "{\"acography_serial_no\"\:\""+empi.ACOGRAPHY_SERIAL_NO+"\",";
			datames += "\"add_date\"\:\""+empi.ADD_DATE+"\",";
			datames += "\"department_name\"\:\""+empi.DEPARTMENT_NAME+"\",";
			datames += "\"doctor_id\"\:\""+empi.DOCTOR_ID+"\",";
			datames += "\"doctor_name\"\:\""+empi.DOCTOR_NAME+"\",";
			datames += "\"modify_date\"\:\""+empi.MODIFY_DATE+"\",";
			datames += "\"patient_birth_date\"\:\""+empi.PATIENT_BIRTH_DATE+"\",";
			datames += "\"patient_gender\"\:\""+empi.PATIENT_GENDER+"\",";
			datames += "\"patient_name\"\:\""+empi.PATIENT_NAME+"\",";
			datames += "\"patient_no\"\:\""+empi.PATIENT_NO+"\",";
			
			for(var i=0;i<empi.DiagnosisList.length;i++){
				patient_zdsm += empi.DiagnosisList[i].diagnosisIcd10;
				patient_zdsm += ";";
			}
			patient_zdsm = patient_zdsm.substring(0,patient_zdsm.length-1);
			datames += "\"patient_zdsm\"\:\""+patient_zdsm+"\",";
			
			if(recipeTreatmentList.length>0){
				for(var i=0;i<recipeTreatmentList.length;i++){
					kdfw += recipeTreatmentList[i].treatmentName;
					kdfw += ";";
				}
			}
			kdfw = kdfw.substring(0,kdfw.length-1);
			datames += "\"kdfw\"\:\""+kdfw+"\",";
			
			datames += "\"treatment_type\"\:\""+empi.TREATMENT_TYPE+"\",";
			datames += "\"agentQty\"\:\""+recipe.agentQty+"\",";
			datames += "\"recipeType\"\:\""+recipe.recipeType+"\",";
			datames += "\"totalPrice\"\:\""+recipe.totalPrice+"\",";
			datames += "\"advice\"\:\""+recipe.advice+"\",";
			datames += "\"recipeId\"\:\""+recipe.recipeId+"\",";
			datames += "\"clinicId\"\:\""+recipe.acography.clinicId+"\",";
			datames += "\"drugList\"\:\[";
			for(var i=0;i<recipeCnList.length;i++){
				datames += "\{\"drugDose\"\:\""+recipeCnList[i].drugDose+"\",";
				datames += "\"drugId\"\:\""+recipeCnList[i].drugId+"\",";
				datames += "\"drugName\"\:\""+recipeCnList[i].drugName+"\",";
				datames += "\"drugSource\"\:\""+recipeCnList[i].drugSource+"\",";
				datames += "\"drugUnitId\"\:\""+recipeCnList[i].drugUnitId+"\",";
				datames += "\"drugUnitName\"\:\""+recipeCnList[i].drugUnitName+"\",";
				datames += "\"unitPrice\"\:\""+recipeCnList[i].unitPrice+"\"},";
			};
			datames = datames.substring(0, datames.length-1);
			datames += "\]\}";
			//console.log(2222,datames);
			if(item.length>0){
				confirm("提示","微信中已有该药方信息，是否再次发送！",function(result){
					if(result){
						$("#MessageWindow").slideDown(300);
				        $("#MessagebackGround").show();
						saveRecipe(datames);
					}
				});
			}else {
				confirm("提示","确认发送！",function(result){
					if(result){
						$("#MessageWindow").slideDown(300);
				        $("#MessagebackGround").show();
						saveRecipe(datames);
					}
				});
			};
		};
		myRequest(url,tn,param,success);
	}
	
	function logginCheck(){
		var success = function(data){
			//console.log("登陆用户确认成功！");
			var item = eval('('+data+')');
			token = item.rybToken;
			console.log("已登陆:"+data);
			var con = '';
			con += "<span class=\"user-name\">"+item.docname +" <strong>"+item.grjj +"</strong></span>";
			con += "<span class=\"user-role\">"+item.sskb2mc +"</span>";
			//console.log("conn:"+con);
			$("#docinfo").html(con);
			$("#hospital").html(item.hospitalname);
			init();
		};
		if(ip.indexOf("localhost")>0){
			init();
		}else{
			dologgincheck(userid,success);
		}
		
	}
	
	function concernPayment(recipeId,patname,userid,username){
	 	var tn = "F27.APP.06.08";
		var param = "{\"recipeId\":\""+recipeId+"\",\"patient_name\":\""+patname+"\",\"userid\":\""+userid+"\",\"username\":\""+username+"\"}";
		var success = function(data){
			//alert("确认成功！");
			console.log("收费确认成功!");
			getPayRecordU();
			getPayRecordN();
			getPayRecordY();
		};
		myRequest(url,tn,param,success);
	}

	function saveSchedule(dataTr){
		var tn = "F27.APP.05.01";
		var param = dataTr;
		var success = function(data){
            $("#MessageWindow").slideUp(300);
            $("#MessagebackGround").hide();
			alert("提示","排班信息同步成功！",function(){
			});
			console.log("排班信息同步成功："+data);
		};
		myRequest(url,tn,param,success);
	}

	//获取已登记的预约患者列表
	function getPatientlistY(){
		var tn = "F27.APP.11.01";
		var param = "{\"hosid\":\""+hosid+"\",\"isregister\":\"y\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已登记:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var paty = item[i];
				con += "<li class = \"second-dropdown-cony\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+paty.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">性别  "+paty.PATIENT_SEX +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">年龄  "+paty.PATIENT_AGE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">电话  "+paty.PATIENT_MOBILE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">病历号  "+paty.PATIENT_BLHM +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">预约日期  "+paty.PRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">预约时间段  "+paty.SLOTAM +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				//console.log("getPatientlistY",item.length);
				$("#conycount").html(item.length);
			}else{
				//console.log("getPatientlistY",item.length);
				$("#conycount").html(null);
			}
			//console.log("cony:"+con);
			$("#cony").html(con);
			
	        $(".second-dropdown-cony > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown-cony").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown-cony").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}

	//获取已登记的预约患者列表
	function getPatientlist3days(){
		var tn = "F27.APP.11.15";
		var param = "{\"hosid\":\""+hosid+"\",\"isregister\":\"n\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已登记:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var paty = item[i];
				con += "<li class = \"second-dropdown-3days\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+paty.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">性别  "+paty.PATIENT_SEX +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">年龄  "+paty.PATIENT_AGE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">电话  "+paty.PATIENT_MOBILE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">病历号  "+paty.PATIENT_BLHM +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">预约日期  "+paty.PRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">预约时间段  "+paty.SLOTAM +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				//console.log("getPatientlist3days",item.length);
				$("#3dayscount").html(item.length);
			}else{
				//console.log("getPatientlist3days",item.length);
				$("#3dayscount").html(null);
			}
			//console.log("3days:"+con);
			$("#3days").html(con);
			
	        $(".second-dropdown-3days > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown-3days").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown-3days").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取患者绑定二维码
	function getWxbindQRcode(patient_blhm,patient_name){
		var tn = "F27.APP.11.08";
		var param = "\{\"wpid\":\""+wpid+"\",\"userid\":\""+userid+"\",\"patient_blhm\":\""+patient_blhm+"\",\"patient_name\":\""+patient_name+"\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		//console.log("param:"+param);
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log(data);
			var con = "<div><img style=\"height\:300px\;\" src=\""+item[0].QRURL+"\"></img></div><div><span>请您尽快扫码绑定微信</span><a title=\""+item[0].PATIENT_NAME+","+item[0].PATIENT_BLHM+"\" id=\"QRcode\">刷新</a></div>";
			$("#qrcode").html(con);
		};
		myRequest(url,tn,param,success);
	}

	//获取未绑定微信患者列表
	function getWxUnbindPatlistY(){
		var tn = "F27.APP.11.07";
		var param = "\{\"hosid\":\""+hosid+"\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已登记:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var unwx = item[i];
				con += "<li class = \"second-dropdown-unwx\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+unwx.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">性别  "+unwx.PATIENT_SEX +"<span title="+unwx.PATIENT_NAME+","+unwx.PATIENT_BLHM +" id=\"QRcode\" class=\"label label-success\">扫码绑定</span></a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">年龄  "+unwx.PATIENT_AGE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">电话  "+unwx.PATIENT_MOBILE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">病历号  "+unwx.PATIENT_BLHM +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#unwxcount").html(item.length);
			}else{
				$("#unwxcount").html(null);
			}
			//console.log("cony:"+con);
			$("#unwx").html(con);
			$(".second-dropdown-unwx > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取待登记患者信息
	function getPatientN(appid){
		var tn = "F27.APP.11.01";
		var param = "{\"hosid\":\""+hosid+"\",\"appid\":\""+appid+"\",\"isregister\":\"n\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("待登记患者信息:"+data);
			var iframeContent = $("#r-main").find("#paFrame").contents();
			//console.log("patiName:"+iframeContent.find("#patiName").length);
			if(iframeContent.find("#patiName").length>0){
				//console.log(iframeContent.find("#patiName"));
				//console.log("SEX:"+item[0].PATIENT_SEX);
				iframeContent.find("#patiName").val(item[0].PATIENT_NAME);
				iframeContent.find("#sex_warpper").val(item[0].SEX_WARPPER);
				iframeContent.find("#birthday").val(item[0].CSRQ);
				iframeContent.find("#age").val(item[0].PATIENT_AGE);
				iframeContent.find("#phone").val(item[0].PATIENT_MOBILE);
				if(item[0].PATNO!=null&&item[0].PATNO!=""){
					iframeContent.find("#patientno").val(item[0].PATNO);
				}
				//iframeContent.find("#patiSource").val(item[0].PATISOURCE);
				iframeContent.find("#guahao-dept").val(item[0].SSKBMC);
				iframeContent.find("#guahao-doctor").val(item[0].DOCNAME);
				clearInterval(InterDoctorRota); 
			}
			//console.log(iframeContent.find("#reg_complete_btn"));
			//console.log(iframeContent.find("#reg_complete_btn").length);
			iframeContent.find("#reg_complete_btn").bind("click",function(){
				var patientno = iframeContent.find("#patientno").val();
				//console.log("patientno:"+patientno);
				var param = "{\"patientno\":\""+patientno;
					param +="\",\"appid\":\""+appid;
					param +="\",\"patient_id\":\""+item[0].PATIENT_ID;
					param +="\",\"patient_name\":\""+item[0].PATIENT_NAME;
					param +="\",\"hosid\":\""+hosid;
					param +="\",\"userid\":\""+userid;
					param +="\",\"username\":\""+username+"\"}";
				console.log(param);
				concernregister(param);
			});
		};
		myRequest(url,tn,param,success);
	}
	
	//确认登记患者
	function concernregister(param){
		var tn = "F27.APP.06.09";
		var success = function(data){
			alert("提示","确认成功！",function(){
				getPatientlistY();
				getPatientlistN();
			});
		};
		myRequest(url,tn,param,success);
	}

	//获取待登记的预约患者列表
	function getPatientlistN(){
		var tn = "F27.APP.11.01";
		var param = "{\"hosid\":\""+hosid+"\",\"isregister\":\"n\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("待登记:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var patn = item[i];
				con += "<li class = \"second-dropdown-conn\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+patn.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">性别  "+patn.PATIENT_SEX +"<span title="+patn.APPID +" id=\"quickAdd\" class=\"label label-success\">一键填入</span></a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">年龄  "+patn.PATIENT_AGE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">电话  "+patn.PATIENT_MOBILE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">就诊日期  "+patn.PRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">就诊时间段  "+patn.SLOTAM +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">预约时间  "+patn.CRE_TIME +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length>0){
				console.log("getPatientlistN",item.length);
				$("#conncount").html(item.length);
				$("#pat_register").html(item.length);
			}else{
				//console.log("getPatientlistN",item.length);
				$("#conncount").html(null);
				$("#pat_register").html(null);
			}
			//console.log("conn:"+con);
			$("#conn").html(con);
			$(".second-dropdown-conn > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取今日开药
	function getOrderListY(){
		var tn = "F27.APP.11.02";
		var param = "{\"hosid\":\""+hosid+"\",\"istoday\":\"y\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"actime\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已登记:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var ordy = item[i];
				con += "<li class = \"second-dropdown-ordy\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+ordy.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">性别  "+ordy.PATIENT_SEX +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">年龄  "+ordy.PATIENT_AGE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">电话  "+ordy.PATIENT_MOBILE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">病历号  "+ordy.PATIENT_BLHM +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">医药费  "+ordy.PRESCRIPTION_PRICE +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length>0){
				$("#ordycount").html(item.length);
				$("#ord_today").html(item.length);
			}else{
				$("#ordycount").html(null);
				$("#ord_today").html(null);
			}
			//console.log("conn:"+con);
			$("#ordy").html(con);
			$(".second-dropdown-ordy > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取已开药方
	function getOrderListN(){
		var tn = "F27.APP.11.02";
		var param = "{\"hosid\":\""+hosid+"\",\"istoday\":\"n\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"actime\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已登记:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var ordn = item[i];
				con += "<li class = \"second-dropdown-ordn\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+ordn.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">性别  "+ordn.PATIENT_SEX +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">年龄  "+ordn.PATIENT_AGE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">电话  "+ordn.PATIENT_MOBILE +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">病历号  "+ordn.PATIENT_BLHM +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">医药费  "+ordn.PRESCRIPTION_PRICE +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#ordncount").html(item.length);
			}else{
				console.log("getOrderListN",item.length);
				$("#ordncount").html(null);
			}
			//console.log("conn:"+con);
			$("#ordn").html(con);
			$(".second-dropdown-ordn > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取支付待确认记录
	function getPayRecordU(){
		var tn = "F27.APP.11.03";
		var param = "{\"hosid\":\""+hosid+"\",\"ispay\":\"u\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("待确认:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var payu = item[i];
				con += "<li class = \"second-dropdown-payu\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+payu.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付结果  "+payu.OP_MSG +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付方式  "+payu.PAY_CLIENT +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">开方时间  "+payu.CRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付时间  "+payu.PAY_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付金额 "+payu.JE_SF +"</a></li>";
				con+="<li id=\"quickConcern\"><a style=\"color:green\">核对收费</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#payucount").html(item.length);
				$("#pay_manage").html(item.length);
			}else{
				$("#payucount").html(null);
				$("#pay_manage").html(null);
			}
			//console.log("conn:"+con);
			$("#payu").html(con);
			$(".second-dropdown-payu > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取未支付记录
	function getPayRecordN(){
		var tn = "F27.APP.11.03";
		var param = "{\"hosid\":\""+hosid+"\",\"ispay\":\"n\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("未支付:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var payn = item[i];
				con += "<li class = \"second-dropdown-payn\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+payn.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付结果  "+payn.OP_MSG +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付方式  "+payn.PAY_CLIENT +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">开方时间  "+payn.CRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付时间  "+payn.PAY_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付金额 "+payn.JE_SF +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#payncount").html(item.length);
			}else{
				$("#payncount").html(null);
			}
			//console.log("conn:"+con);
			$("#payn").html(con);
			$(".second-dropdown-payn > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取已支付记录
	function getPayRecordY(){
		var tn = "F27.APP.11.03";
		var param = "{\"hosid\":\""+hosid+"\",\"ispay\":\"y\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"cre_time\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已支付:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var payy = item[i];
				con += "<li class = \"second-dropdown-payy\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+payy.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付结果  "+payy.OP_MSG +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付方式  "+payy.PAY_CLIENT +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">开方时间  "+payy.CRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付时间  "+payy.PAY_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付金额 "+payy.JE_SF +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#payycount").html(item.length);
			}else{
				$("#payycount").html(null);
			}
			//console.log("conn:"+con);
			$("#payy").html(con);
			$(".second-dropdown-payy > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取未发药信息
	function getOrderDeliverN(){
		var tn = "F27.APP.11.09";
		var param = "{\"hosid\":\""+hosid+"\",\"ordstatus\":\"3\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"actime\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已支付:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var deli_n = item[i];
				con += "<li class = \"second-dropdown-deli_n\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+deli_n.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付结果  "+deli_n.OP_MSG +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">开方时间  "+deli_n.CRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付时间  "+deli_n.PAY_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">发药时间 "+deli_n.DELIVER_TIME +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#deliverncount").html(item.length);
				$("#ord_deliver").html(item.length);
			}else{
				$("#deliverncount").html(null);
				$("#ord_deliver").html(null);
			}
			//console.log("conn:"+con);
			$("#deli_n").html(con);
			$(".second-dropdown-deli_n > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取已发药信息
	function getOrderDeliverY(){
		var tn = "F27.APP.11.09";
		var param = "{\"hosid\":\""+hosid+"\",\"ordstatus\":\"4\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"actime\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已支付:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var deli_y = item[i];
				con += "<li class = \"second-dropdown-deli_y\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+deli_y.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付结果  "+deli_y.OP_MSG +"<span title="+deli_y.PRESCRIPTION_ID +" id=\"doPrintReceive\" class=\"label label-success\">打印收货单</span></a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">开方时间  "+deli_y.CRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付时间  "+deli_y.PAY_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">发药时间 "+deli_y.DELIVER_TIME +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#deliverycount").html(item.length);
			}else{
				$("#deliverycount").html(null);
			}
			//console.log("conn:"+con);
			$("#deli_y").html(con);
			$(".second-dropdown-deli_y > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}
	
	//获取已收药信息
	function getOrderTake(){
		var tn = "F27.APP.11.09";
		var param = "{\"hosid\":\""+hosid+"\",\"ordstatus\":\"5\",\"rowsperpage\":\"200\",\"page\":\"1\",\"ordercolumn\":\"actime\",\"ordertype\":\"desc\"}";
		var success = function(data){
			var item = eval('('+data+')').DATAOBJ.DATA;
			//console.log("已支付:"+item);
			var con = '';
			for(var i=0;i<item.length;i++){
				var take_y = item[i];
				con += "<li class = \"second-dropdown-take_y\"><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">"+take_y.PATIENT_NAME +"</a>";
				con += "<div class=\"second-submenu\"><ul>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付结果  "+take_y.OP_MSG +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">开方时间  "+take_y.CRE_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">支付时间  "+take_y.PAY_TIME +"</a></li>";
				con+="<li><a><img class=\"yuanquan-icon\" src=\""+ip+"/doctor/plug_in/icon/yuanquan.png\">发药时间 "+take_y.DELIVER_TIME +"</a></li>";
				con += "</ul></div></li>";
			}
			if(item.length){
				$("#takecount").html(item.length);
			}else{
				$("#takecount").html(null);
			}
			//console.log("conn:"+con);
			$("#take_y").html(con);
			$(".second-dropdown-take_y > a").click(function(){
		        $(".second-submenu").slideUp(250);
	        	if ($(this).parent().hasClass("active")){
	 		         $(".second-dropdown").removeClass("active");
	 		         $(this).parent().removeClass("active");
	        	}else{
	        		$(".second-dropdown").removeClass("active");
	        		$(this).next(".second-submenu").slideDown(250);
	        	 	$(this).parent().addClass("active");
	        	}
	
	        });
		};
		myRequest(url,tn,param,success);
	}

    function getCurrenttiem() {
        var date = new Date();
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate;
        //console.log("currentdate",currentdate);
        return currentdate;
    };

	//查询医师排班
	function getSchedule(){
		 
	    var url = 'https://gp.pinganwj.com/i/apptSchedule/getApptSchedule';
	    var currenttime = getCurrenttiem();
	    var data = {
		  "DEPARTMENT_ID": "",
		  "QUERY_TYPE": "DEPT",
		  "START_DATE": currenttime,
	    };
	    var datatemp = '';
	    var respSuccess = function(resp){
	    	//console.log(resp);
	    	var dataTr = "\{\"dataTr\"\:\[";
	    	var amdata = resp.data[2];
	    	var pmdata = resp.data[3];
	      	//console.log("上午：",amdata[1]);
	      	for(var i=1;i<8;i++){
	      		for(var j=1;j<amdata[i].length;j++){
	      			dataTr += "\{\"clinic_id\"\:\"" +amdata[i][j].CLINIC_ID+"\",";
	      			dataTr += "\"doctor_id\"\:\"" +amdata[i][j].DOCTOR_ID+"\",";
	      			dataTr += "\"femployeename\"\:\"" +amdata[i][j].FEMPLOYEENAME+"\",";
	      			dataTr += "\"fschedate\"\:\"" +amdata[i][j].FSCHEDATE+"\",";
	      			dataTr += "\"amstay\"\:\"y\",";
	      			dataTr += "\"pmstay\"\:\"n\",";
	      			dataTr += "\"onduty\"\:\"am\",";
	      			dataTr += "\"fscheduleid\"\:\"" +amdata[i][j].FSCHEDULEID+"\"\}";
	      			dataTr += ",";
	      		}
	      	}
	      	for(var i=1;i<8;i++){
	      		for(var j=1;j<pmdata[i].length;j++){
	      			dataTr += "\{\"clinic_id\"\:\"" +pmdata[i][j].CLINIC_ID+"\",";
	      			dataTr += "\"doctor_id\"\:\"" +pmdata[i][j].DOCTOR_ID+"\",";
	      			dataTr += "\"femployeename\"\:\"" +pmdata[i][j].FEMPLOYEENAME+"\",";
	      			dataTr += "\"fschedate\"\:\"" +pmdata[i][j].FSCHEDATE+"\",";
	      			dataTr += "\"amstay\"\:\"n\",";
	      			dataTr += "\"pmstay\"\:\"y\",";
	      			dataTr += "\"onduty\"\:\"pm\",";
	      			dataTr += "\"fscheduleid\"\:\"" +pmdata[i][j].FSCHEDULEID+"\"\}";
	      			dataTr += ",";
	      		}
	      	}
	      	dataTr = dataTr.substring(0, dataTr.length-1);
	      	dataTr += "\]\}";
		  	//console.log("排班测试！！！",dataTr);
		  	saveSchedule(dataTr);
	    };
	    doPostRequest(url, data, respSuccess, datatemp);
	}
	
	//查询患者登记列表
	function getRegPatientlist(){
		var datatemp = '';
		var currenttime = getCurrenttiem();
		//console.log("beginDate:",beginDate);
		//console.log("endDate:",endDate);
	    var url = 'https://gp.pinganwj.com/i/empi/getPatinetRecordPage';
	    var data = {
		  	"ajaxopts": {
				"showMask": true,
				"type": "POST",
				"url": "https://gp.pinganwj.com/i/empi/getPatinetRecordPage",
				},
			"beginDate": currenttime+" 00:00:00",
			"containerId": "my-page",
			"currentPage": 1,
			"currentPageKey": null,
			"dataKey": null,
			"endDate": currenttime+" 23:59:59",
			"keyword": "",
			"listType": null,
			"pageCount": 0,
			"pageSize": 20,
			"pageSizeDefault": 20,
			"patientLab": "",
			"patientSource": "",
			"tableBody": null,
			"totalPageKey": null,
			"visitDepartment": "",
			"visitDoctor": "",
			"visitStatus": "",
			"visitType": "",
	    };
	    var respSuccess = function(resp){
	    	var item = resp.data.dataSource;
	    	var patinfo = "\{\"reqpatlist\"\:\[";
	    	console.log(1,item);
	    	if(item!=null&&item.length>0){
	    		for(var i=0;i<item.length;i++){
	    			if(item[i].IS_TRIAGE=='1'){
				    	var patient_name = '';
				    	var patient_sex = '';
				    	var patient_csrq = '';
				    	var patient_mobile = '';
				    	var patient_blhm = '';
				    	var pati_source = '';
				    	if(item[i].PATIENT_NAME!=null){
				    		patient_name = item[i].PATIENT_NAME;
				    	}
				    	if(item[i].PATIENT_GENDER!=null){
				    		patient_sex = item[i].PATIENT_GENDER;
				    	}
				    	if(item[i].PATIENT_BIRTH_DATE!=null){
				    		patient_csrq = item[i].PATIENT_BIRTH_DATE;
				    	}
				    	if(item[i].MOBILE_PHONE_NUMBER!=null){
				    		patient_mobile = item[i].MOBILE_PHONE_NUMBER;
				    	}
				    	if(item[i].PATIENT_NO!=null){
				    		patient_blhm = item[i].PATIENT_NO;
				    	}
				    	if(item[i].PAT_SOURCE_NAME!=null){
				    		pati_source = item[i].PAT_SOURCE_NAME;
				    	}
						patinfo += "\{\"patient_name\"\:\""+patient_name+"\",";
						patinfo += "\"patient_sex\"\:\""+patient_sex+"\",";
						patinfo += "\"patient_csrq\"\:\""+patient_csrq+"\",";
						patinfo += "\"patient_mobile\"\:\""+patient_mobile+"\",";
						patinfo += "\"patient_blhm\"\:\""+patient_blhm+"\",";
						patinfo += "\"pati_source\"\:\""+pati_source+"\",";
						patinfo += "\"hosid\"\:\""+hosid+"\"\},";
	    			}
	    		};
	    		patinfo = patinfo.substring(0,patinfo.length-1);
	    		patinfo += "\]\}";
	    	};
			//console.log("patinfo:"+patinfo);
			savePatInfo(patinfo);
	    };
	    doPostRequest(url, data, respSuccess, datatemp);
	}
	
	//查询中草药方
	function getRecipe(datatemp){
		 
	    var url = 'https://gp.pinganwj.com/i/TCMPrescription/getHerbalRecipes';
	    var data = {
		  "empiId": "343ad0f3cb7f4197b0f68782a61e3d70",
		  "acographyId": "ea03f54f985d41c78e84c2e380d6d1ab",
	    };
	    var respSuccess = function(resp){
			var ono = resp.data.empi.ACOGRAPHY_SERIAL_NO;
			console.log(1111,ono);
			checkOrder(ono,resp);
	    };
	    doPostRequest(url, data, respSuccess, datatemp);
	}
	//同步中草药到后台
	function saveRecipe(datames){
		var tn = "F27.APP.11.04";
		var param = datames;
		var success = function(data){
			console.log("测试成功："+data);
            $("#MessageWindow").slideUp(300);
            $("#MessagebackGround").hide();
			alert("提示","发送成功！",function(){
				getOrderListY();
				getPayRecordN();
				$("#hzdj").hide(1000);
	        	$("#jrjz").show(1000);
	        	$("#sfgl").hide(1000);
        		$("#yffh").hide(1000);
			});
		};
		myRequest(url,tn,param,success);
	}
	
	//请求
	//执行本地请求
	function myRequest(url,tn,param,success){
			
			var message = "{\"OTRequest\":  {\"VERSION\":\"1.0\",   \"TN\":\""+
						tn+"\",   \"CLIENTID\":\"YLAPP\",   \"RYBID\":\"WEBPLUS_PAWJ\", \"TOKEN\":\""+token+"\" , \"DATA\":"+
						param+"}}";//WEBPLUS_PAWJ   rybid 等程序调好后填入  常量
			if(ip.indexOf("localhost")>0){
				message = "{\"OTRequest\":  {\"VERSION\":\"1.0\",   \"TN\":\""+
						tn+"\",   \"CLIENTID\":\"YLAPP\",   \"RYBID\":\"\", \"TOKEN\":\""+token+"\" , \"DATA\":"+
						param+"}}";
			}
			//console.log(message);
			
			var myRequest = new Request.HTML({
			
				url: url,   
			    
			    xhrFields: {  
			      withCredentials: true // 设置运行跨域操作  
			    },  
					
				onRequest: function(){
					//console.log("正在请求...");
				},
				
				//成功的回调函数
				onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
	        		success(responseHTML);
				},
				
				//失败的回调函数. 404. 500. 以及返回JSON串success为false时执行
				onFailure: function(xhr){ //alert(2);
				   //alert(xhr.responseText);
				   console.log(xhr.responseText);
				}
			});
			
			//console.log(message);
			
			myRequest.send(message);
		}
		
	  	function dologgincheck(userid,success){
	  	
			var cha = '<%=ip %>/doctor/WeixinLogin.lg?reqType=login&RYBID=WEBPLUS_PAWJ&USERID='+ userid+'&DATA='+hosid;
		    //console.log(userid,cha);
		    var data = {
		    };
		    
			$.ajax({
		      url: cha,
		      method: "POST",
		      data: JSON.stringify(data),
		      headers:{
		        "Content-Type":"application/json; charset=UTF-8",
		        "Accept": "application/json, text/javascript, */*; q=0.01"
		      },
		      beforeSend: function(){
		      },
		      complete: function(){
		      },
		      success:function(data){
		        success(data);
		      },
		      error:function(data) {
		      }
		    });
	  	}
		
	  //执行平安万家请求  没有调通，没在用
	  function doPostRequest(url,data,respSuccess,datatemp){
	    url += "?cookie_pawj_medical_user_id=" + $.cookie('cookie_pawj_medical_user_id')+datatemp;
	    //console.log(url);
	    $.ajax({
	      url: url,
	      method: "POST",
	      data: JSON.stringify(data),
	      headers:{
	        "Content-Type":"application/json; charset=UTF-8",
	        "Accept": "application/json, text/javascript, */*; q=0.01"
	      },
	      beforeSend: function(){
	      },
	      complete: function(){
	      },
	      success:function(data){
	        respSuccess(data);
	      },
	      error:function(data) {
	      }
	    });
	  }
	  
	  //悬浮框
	  $(document).ready(function(){

          $("#x").click(function(){
              $("#QRcodeWindow").slideUp(300);
              $("#QRcodebackGround").hide();
              getWxUnbindPatlistY();
              clearInterval(InterDoctorRota);
          });
          $("#msg-x").click(function(){
              $("#MessageWindow").slideUp(300);
              $("#MessagebackGround").hide();
              clearInterval(InterDoctorRota);
          });
          $("#deli_x").click(function(){
              $("#deliverWindow").slideUp(300);
              $("#deliverbackGround").hide();
          });
          $("#cancel").click(function(){
              $("#deliverWindow").slideUp(300);
              $("#deliverbackGround").hide();
          });
          $("#printx").click(function(){
              $("#QRcodePrint").slideUp(300);
              $("#PrintbackGround").hide();
          });

      });

//插件列表下拉显示和底部切换
  jQuery(function($) {
  
        $(".sidebar-hzdj").click(function(){
        	$("#hzdj").show(1000);
        	$("#jrjz").hide(1000);
        	$("#sfgl").hide(1000);
        	$("#yffh").hide(1000);
        	getPatientlistY();
			getPatientlistN();
			getPatientlist3days();
			getWxUnbindPatlistY();
        });
  
        $(".sidebar-jrjz").click(function(){
        	$("#hzdj").hide(1000);
        	$("#jrjz").show(1000);
        	$("#sfgl").hide(1000);
        	$("#yffh").hide(1000);
        	getOrderListY();
			getOrderListN();
        });
  
        $(".sidebar-sfgl").click(function(){
        	$("#hzdj").hide(1000);
        	$("#jrjz").hide(1000);
        	$("#sfgl").show(1000);
        	$("#yffh").hide(1000);
        	getPayRecordU();
			getPayRecordN();
			getPayRecordY();
        });
  
        $(".sidebar-yffh").click(function(){
        	$("#hzdj").hide(1000);
        	$("#jrjz").hide(1000);
        	$("#sfgl").hide(1000);
        	$("#yffh").show(1000);
        	getOrderDeliverN();
			getOrderDeliverY();
			getOrderTake();
        });
        
        $(".sidebar-dropdown > a").click(function(){
	        $(".sidebar-submenu").slideUp(250);
        	if ($(this).parent().hasClass("active")){
 		         $(".sidebar-dropdown").removeClass("active");
 		         $(this).parent().removeClass("active");
        	}else{
        		$(".sidebar-dropdown").removeClass("active");
        		$(this).next(".sidebar-submenu").slideDown(250);
        	 	$(this).parent().addClass("active");
        	}

        });
		
         $("#toggle-sidebar").click(function(){
	         $(".plug-in-page").toggleClass("toggled");	    
       	 });

    });
</script>
<script>
	(function($){
	$.alerts={
		alert: function(title,message,callback){
			if(title==null)
			title='Alert';
			$.alerts._show(title,message,null,'alert',function(result){
				if(callback)
				callback(result);
			});
		},
		confirm: function(title,message,callback){
			if(title==null)
			title='Confirm';
			console.log(111000,title,message,callback);
			$.alerts._show(title,message,null,'confirm',function(result){
				if(callback)
				callback(result);
			});
		},
		_show: function(title,msg,value,type,callback){
			var _html="";
			_html+='<div id="mb_box"></div><div id="mb_con"><span id="mb_tit">'+title+'</span>';
			_html+='<div id="mb_msg">'+msg+'</div><div id="mb_btnbox">';
			if(type=="alert"){
				_html+='<input id="mb_btn_ok" type="button" value="确定"/>';
			}
			if(type=="confirm"){
				_html+='<input id="mb_btn_ok" type="button" value="确定"/>';
				_html+='<input id="mb_btn_no" type="button" value="取消"/>';
			}
			_html+='</div></div>';
			//必须先将_html添加到body，再设置Css样式
			$("body").append(_html);
			GenerateCss();
			switch(type){
				case 'alert': 
				$("#mb_btn_ok").click(function(){
					$.alerts._hide();
					callback(true);
				});
				$("#mb_btn_ok").focus().keypress(function(e){
					if(e.keyCode==13||e.keyCode==27)
					$("#mb_btn_ok").trigger('click');
				});break;
				case 'confirm': 
				$("#mb_btn_ok").click(function(){
					$.alerts._hide();
					if(callback)
					callback(true);
				});
				$("#mb_btn_no").click(function(){
					$.alerts._hide();
					if(callback)
					callback(false);
				});
				$("#mb_btn_no").focus();
				$("#mb_btn_ok, #mb_btn_no").keypress(function(e){
					if(e.keyCode==13)
					$("#mb_btn_ok").trigger('click');
					if(e.keyCode==27)
					$("#mb_btn_no").trigger('click');
				});break;
			}
		},
		_hide: function(){
			$("#mb_box,#mb_con").remove();
		}
	};
	//Shortuct functions
	window.alert=function(title,message,callback){
		$.alerts.alert(title,message,callback);
	};
	window.confirm=function(title,message,callback){
		$.alerts.confirm(title,message,callback);
	};
	//生成Css
	var GenerateCss=function(){
		$("#mb_box").css({
			width: '100%',
			height: '100%',
			zIndex: '99999',
			position: 'fixed',
			filter: 'Alpha(opacity=60)',
			backgroundColor: 'black',
			top: '0',
			left: '0',
			opacity: '0.6',
		});
		$("#mb_con").css({
			zIndex: '999999',
			width: '35%',
			position: 'fixed',
			backgroundColor: 'White',
			borderRadius: '15px',
		});
		$("#mb_tit").css({
			display: 'block',
			fontSize: '14px',
			color: '#444',
			padding: '10px 15px',
			backgroundColor: '#DDD',
			borderRadius: '15px 15px 00',
			borderBottom: '3px solid #4caf50',
			fontWeight: 'bold',
		});
		$("#mb_msg").css({
			padding: '20px',
			lineHeight: '20px',
			borderBottom: '1px dashed #DDD',
			fontSize: '13px',
		});
		$("#mb_ico").css({
			display: 'block',
			position: 'absolute',
			right: '10px',
			top: '9px',
			border: '1px solid Gray',
			width: '18px',
			height: '18px',
			textAlign: 'center',
			lineHeight: '16px',
			cursor: 'pointer',
			borderRadius: '12px',
			fontFamily: '微软雅黑',
		});
		$("#mb_btnbox").css({
			margin: '15px 0 10px 0',
			textAlign: 'center',
		});
		$("#mb_btn_ok,#mb_btn_no").css({
			width: '85px',
			height: '25px',
			color: 'white',
			border: 'none',
		});
		$("#mb_btn_ok").css({
			backgroundColor: '#4caf50',
		});
		$("#mb_btn_no").css({
			backgroundColor: 'gray',
			marginLeft: '20px',
		});
		//右上角关闭按钮hover样式
		$("#mb_ico").hover(function(){
			$(this).css({
				backgroundColor: 'Red',
				color: 'White'
			});
		},
		function(){
			$(this).css({
				backgroundColor: '#DDD',
				color: 'black'
			});
		});
		var _widht=document.documentElement.clientWidth;//屏幕宽
		var _height=document.documentElement.clientHeight;//屏幕高
		var boxWidth=$("#mb_con").width();
		var boxHeight=$("#mb_con").height();//让提示框居中
		$("#mb_con").css({
			top: (_height-boxHeight)/2+"px",
			left: (_widht-boxWidth)/2+"px",
		});
	};
})(jQuery);
</script>
